package io.renren.modules.xm.service.impl;

import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.modules.xm.dao.OrderInfoDao;
import io.renren.modules.xm.entity.OrderInfoEntity;
import io.renren.modules.xm.service.OrderInfoService;
import javax.annotation.Resource;


@Service("orderInfoService")
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoDao, OrderInfoEntity> implements OrderInfoService {

    @Resource
    OrderInfoDao orderInfoDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        int current =  Integer.parseInt((String)params.get("page"));
        int limit =  Integer.parseInt((String)params.get("limit"));
        params.put("page",(current-1)*limit);
        params.put("limit",limit);

        int total = orderInfoDao.count(params);
        Page<OrderInfoEntity> page = new Page<>(current,limit);
        List<OrderInfoEntity> list = orderInfoDao.queryPage(params);
        page.setRecords(list);
        page.setTotal(total);

        return new PageUtils(page);
    }

}
